﻿
Namespace PL.MESSDK
    Public Class SampleDetail_PL
        Inherits PLBase

        Public Sub New()
            MyBase.New()
        End Sub

        Public Sub New(ByVal queryName As String)
            MyBase.New(queryName)
        End Sub

        Sub OnRowUpdating(ByVal sender As Object, ByVal e As SqlRowUpdatingEventArgs) Handles MetaDataTable.OnRowUpdating

        End Sub

        Public Overrides Function Delete() As Boolean
            'Throw New NotImplementedException("Delete To Come...")
            Return False
        End Function

        Public Overrides Function Validate() As Boolean
            'Throw New NotImplementedException("Validate To Come...")
            Return True
        End Function

        ''' <summary>
        ''' Validate a SampleDetail DataRow
        ''' </summary>
        ''' <param name="row"></param>
        ''' <remarks>Errors are saved with row.SetColumnError method</remarks>
        Public Overrides Sub ValidateRow(row As DataRow)
            row.ClearErrors()
         
            If row.Table.Columns.Contains("RepetNmbr") Then
                If IsDBNull(row("RepetNmbr")) Then
                    row.SetColumnError("RepetNmbr", "Mandatory")
                End If
            End If
            If row.Table.Columns.Contains("TNTC") Then
                If IsDBNull(row("TNTC")) Then
                    row.SetColumnError("TNTC", "Mandatory")
                End If
            End If
            If row.Table.Columns.Contains("Valid") Then
                If IsDBNull(row("Valid")) Then
                    row.SetColumnError("Valid", "Mandatory")
                End If
            End If
            If row.Table.Columns.Contains("CompulsoryRep") Then
                If IsDBNull(row("CompulsoryRep")) Then
                    row.SetColumnError("CompulsoryRep", "Mandatory")
                End If
            End If
            If row.Table.Columns.Contains("Reject") Then
                If IsDBNull(row("Reject")) Then
                    row.SetColumnError("Reject", "Mandatory")
                End If
            End If
            If row.Table.Columns.Contains("ResultDisplay") Then
                If IsDBNull(row("ResultDisplay")) Then
                    row.SetColumnError("ResultDisplay", "Mandatory")
                End If
            End If

            If row.HasErrors Then
                row.RowError = "Please check your columns, a validation error occur"
            End If
        End Sub

    End Class
End Namespace

